package com.lyt.springboot.designPattern.strategyPattern;

// 转发上下文，使用策略对象
class ForwardingContext {
    private ForwardingStrategy strategy;

    // 构造函数，设置具体策略
    public ForwardingContext(ForwardingStrategy strategy) {
        this.strategy = strategy;
    }

    // 转发方法，调用策略对象的forward方法
    public void forwardMessage(String message) {
        strategy.forward(message);
    }

    // 允许动态改变策略
    public void setStrategy(ForwardingStrategy strategy) {
        this.strategy = strategy;
    }
}